<?php
class Model_FilterValue extends Zend_Db_Table_Abstract{
	protected $_name = "filter_value";
	protected $_referenceMap = array(
			"Filter" => array(
				"columns" => "filter_id",
				"refTableClass" => "Model_Filter",
				"refColumns" => "id"
			)
		
	);
	public function getFilterValueByID($id){
		return $this->find($id)->current();
	}
	public function createFilterValue($text, $filter_id){
		$filterValue = $this->createRow();
		$filterValue->text = $text;
		$filterValue->filter_id = $filter_id;
		$filterValue->save();
		return $this->_db->lastInsertId();
	}
	public function updateFilterValue($id, $text, $filter_id){
		try{
			$this->update(array('text' => $text, 'filter_id' => $filter_id), 'id='.$id);
			return true;
		}catch (Exception $ex){
			echo "Caught Exception: ".$ex->getMesssage();
			return false;
		}
	}
	public function deleteFilterValue($id){
		return $this->delete('id='.$id);
	}
}